package com.example.adapter;

import com.chinator.chinator_v2.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class AdaptadorSpinner extends ArrayAdapter<String>{
	
	private LayoutInflater miInflater;
	private String[] rellenoDelSpinner;
	private int[] imagenes;
	
    public AdaptadorSpinner(Context context, int textViewResourceId,String[] objects,int[] imagenes) {
        super(context, textViewResourceId, objects);
		miInflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		rellenoDelSpinner=objects;
		this.imagenes=imagenes;
    }
    
    @Override
    public View getDropDownView(int position, View convertView,ViewGroup parent) {
        return getCustomView(position, convertView, parent);
    }
    
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        return getCustomView(position, convertView, parent);
    }
    
    public View getCustomView(int position, View convertView, ViewGroup parent) {

        View row=miInflater.inflate(R.layout.forma_row, parent, false);
        TextView label=(TextView)row.findViewById(R.id.textoColumna);
        label.setText(rellenoDelSpinner[position]);
        
        ImageView imagen= (ImageView)row.findViewById(R.id.imagenRow);
        imagen.setImageResource(imagenes[position]);
        imagen.setTag(imagenes[position]);
        
        return row;

    }

}
